home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / pnl003.zip / TOKEN.PAS < prev   
Pascal/Delphi Source File  |  1990-05-30  |  14KB  |  173 lines

  1. {************************************************************************       
  2. **                                                                              
  3. ** Token.pas  Advanced string handling procedures.                              
  4. **                                                                              
  5. ** Written by G.Hoogterp                                                        
  6. ** All Copyrights reserved                                                      
  7. ** Version 1.0                                                                  
  8. **                                                                              
  9. ** Use this unit as you like, you may modify it for personal use.               
  10. ** you may NOT distribute a modified version though!                            
  11. **                                                                              
  12. *************}                                                                  
  13. Unit Token;                                                                     
  14. Interface                                                                       
  15.                                                                                 
  16.                                                                                 
  17. {***********************************************************************        
  18. **                                                                              
  19. ** Findtoken splits a tokenlist into a head and a tail.                         
  20. **                                                                              
  21. **********}                                                                     
  22.                                                                                 
  23. Function FindToken(Var TokenList : String;Delimiters : String):String;          
  24.                                                                                 
  25. {***********************************************************************        
  26. **                                                                              
  27. ** SimplifyDelimiter simplifies the delimiters in a tokenlist.                  
  28. **                                                                              
  29. **********}                                                                     
  30.                                                                                 
  31. Procedure SimplifyDelimiters(Var TokenList : String;Delimiters : String);       
  32.                                                                                 
  33. {***********************************************************************        
  34. **                                                                              
  35. ** SkipLeadingSpaces deletes the leading spaces of a tokenlist                  
  36. **                                                                              
  37. **********}                                                                     
  38.                                                                                 
  39. Procedure SkipLeadingSpaces(Var TokenList : String);                            
  40.                                                                                 
  41. {***********************************************************************        
  42. **                                                                              
  43. ** DeletetrailingSpaces deletes the trailing spaces of a tokenlist              
  44. **                                                                              
  45. **********}                                                                     
  46.                                                                                 
  47. Procedure DeleteTrailingSpaces(Var TokenList : String);                         
  48.                                                                                 
  49. {***********************************************************************        
  50. **                                                                              
  51. ** UpStr converts a tokenlist to all uppercase                                  
  52. ** DownStr converts a tokenlist to all lowercase                                
  53. **                                                                              
  54. **********}                                                                     
  55.                                                                                 
  56. Procedure UpStr(Var TokenList : String);                                        
  57. Procedure DownStr(Var TokenList : String);                                      
  58.                                                                                 
  59. {***********************************************************************        
  60. **                                                                              
  61. ** Delete noise deletes all charactes you don't want to find in a tokenlist.    
  62. **                                                                              
  63. **********}                                                                     
  64.                                                                                 
  65. Procedure DeleteNoise(Var TokenList : String;Noise : String);                   
  66.                                                                                 
  67. {***********************************************************************        
  68. **                                                                              
  69. ** Replace token can be used to change multiletter delimiters into              
  70. ** single letter delimiters. (Or an other multiletter delimiter)                
  71. **                                                                              
  72. **********}                                                                     
  73.                                                                                 
  74. Procedure ReplaceToken(Var TokenList : String;Tok1,Tok2 : String);              
  75.                                                                                 
  76.                                                                                 
  77. Implementation                                                                  
  78.                                                                                 
  79. Function FindToken(Var TokenList : String;Delimiters : String):String;          
  80. Var HStr : String;                                                              
  81.     Tel  : Byte;                                                                
  82. Begin                                                                           
  83. HStr:='';                                                                       
  84. Tel:=1;                                                                         
  85. While (Tel<=Length(TokenList)) And                                              
  86.       (Pos(UpCase(TokenList[Tel]),Delimiters)=0) Do                             
  87.  HStr:=HStr+TokenList[Tel];                                                     
  88.  Inc(Tel);                                                                      
  89.  End;                                                                           
  90. FindToken:=HStr;                                                                
  91. Delete(TokenList,1,Tel);                                                        
  92. End;                                                                            
  93.                                                                                 
  94. Procedure SimplifyDelimiters(Var TokenList : String;Delimiters : String);       
  95. Var DelTel  : Byte;                                                             
  96. Begin                                                                           
  97. DelTel:=1;                                                                      
  98. Repeat                                                                          
  99. If (Pos(TokenList[DelTel],Delimiters)>0) And                                    
  100.    (Pos(TokenList[DelTel+1],Delimiters)>0)